import collections

f=open('c:\python27\data.txt')
f.seek(0)
#count={}
features={}
featureNameList=[]
featureCounts= collections.defaultdict(lambda:1)
featureVectors=[]
predictCounts=collections.defaultdict(lambda:0)
#for line in f:
#   a=line.split()
#  for word in a:
#     featureVectors.append(word)
a={}

for line in f:
    if line[0]!='@':
        featureVectors.append(line.strip('').strip('\n').lower().split(','))
    else:
        if line.strip(' ').lower().find('@data')==-1 and (not line.lower().startswith('@relation')):
            featureNameList.append(line.strip(' ').split()[1])
            features[featureNameList[len(featureNameList)-1]]=line[line.find('{')+1:line.find('}')].strip(' ').split(',')
                
f.close()

#print featureVectors
# print featureNameList
# print features


for fv in featureVectors:
    for a in range(len(fv)):
        predictCounts[fv[a]]+=1
        
    
    #predictCounts[fv[len(fv)-1]]+=1
#     predictCounts[fv[0]]+=1
#     predictCounts[fv[1]]+=1
#     predictCounts[fv[2]]+=1
#     predictCounts[fv[3]]+=1
#     predictCounts[fv[4]]+=1
  

  # predictCounts.iteritems()
    
#     for counter in range(0,len(fv)-1):
#         featureCounts[(fv[len(fv)-1],featureNameList[counter],fv[counter])]+=1
#     

#print predictCounts


# X=['middle-aged','medium','no','fair']
# print X
# 
# for k in X:
#     print k
#     print predictCounts[k]
"""Probability of give instance X is computed as"""

    
 
prob={'c_yes':0,'c_no':0}

